﻿using System.Data;
using Microsoft.ApplicationBlocks.Data;

namespace DataObject.Comment
{
    public class CommentDAL
    {
        /***************************************
        = Back End
        -------------------------------------- */
        public static void Comment_Update_Status(int commentId, int status)
        {
            SqlHelper.ExecuteNonQuery(Constants.ConnectionString, "Comment_Update_Status", commentId, status);
        }

        public static void Comment_Delete(int commentId)
        {
            SqlHelper.ExecuteScalar(Constants.ConnectionString, "Comment_Delete", commentId);
        }

        public static IDataReader Comment_GetById(int commentId)
        {
            return SqlHelper.ExecuteReader(Constants.ConnectionString, "Comment_GetById", commentId);
        }

        public static int Comment_GetStatistic(int status)
        {
            return (int)SqlHelper.ExecuteScalar(Constants.ConnectionString, "Comment_GetStatistic", status);
        }

        /***************************************
        = Front End
        -------------------------------------- */
        public static int Comment_Create(CommentObject o)
        {
            return (int)SqlHelper.ExecuteScalar(Constants.ConnectionString, "Comment_Create", o.Id, o.ParentId, o.TypeId, o.Status, o.UserName, o.Email, o.Avatar, o.Body);
        }

        public static IDataReader Comment_GetByParentId(int id, int parentId, int status)
        {
            return SqlHelper.ExecuteReader(Constants.ConnectionString, "Comment_GetByParentId", id, parentId, status);
        }        
    }
}
